package com.amsp.oa.oademo.service.impl;

import com.amsp.oa.oademo.entity.FixedAssetLabel;
import com.amsp.oa.oademo.mapper.FixedAssetLabelMapper;
import com.amsp.oa.oademo.service.FixedAssetLabelService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class FixedAssetLabelServiceImpl extends ServiceImpl<FixedAssetLabelMapper, FixedAssetLabel>
        implements FixedAssetLabelService {

    @Override
    public Page<FixedAssetLabel> list(Integer current, Integer size) {
        Page<FixedAssetLabel> page = new Page<>(current, size);
        return this.page(page);
    }

    @Override
    public FixedAssetLabel getById2(Long id) {
        return this.baseMapper.selectById(id);
    }

    @Override
    public boolean saveOrUpdate2(FixedAssetLabel fixedAssetLabel) {
        LocalDateTime now = LocalDateTime.now();
        if (fixedAssetLabel.getId() == null) {
            fixedAssetLabel.setCreateTime(now);
        }
        fixedAssetLabel.setUpdateTime(now);
        return this.saveOrUpdate(fixedAssetLabel);
    }

    @Override
    public boolean delete2(Long id) {
        return this.removeById(id);
    }
}